/*
 * LoaderAC.h
 *
 *  Created on: May 4, 2011
 *      Author: alki
 */

#include "Loader.h"

#ifdef LOADERAC_TAGS
#undef LOADERAC_TAGS

enum OBJECTTYPE { world,group,poly };
enum TAG { AC3D,MATERIAL,OBJECT,NUL };
enum MATERIALTAG { rgb,amb,emis,spec,shi,trans,reflec,refrac };
enum OBJECTTAG { name,data,crease,texture,texrep,rot,loc,url,numvert,kids,SURF };
enum SURFTAG { mat,refs };

class SURFACE {
public:
	vector<unsigned int> vertex;
	vector<float> u,v;
	unsigned int material;
	unsigned int tex;
};

#endif

#ifndef LOADERAC_H_
#define LOADERAC_H_

#include <iostream>
#include <fstream>

class SURFACE;

class LoaderAC : public Loader {
public:
	LoaderAC();
	virtual ~LoaderAC();

	void LoadFile(string filename,vector<Objekt> &objekte,MaterialManager &matman);

private:
	ifstream m_file;

	int ReadTagLine(string &line);

	void ReadHeader(const string &line);
	void ReadMaterial(const string &line);
	void ReadObject(int type);

	vector<Objekt> m_objekte;
	vector<Material> m_materialien;
	vector<Textur> m_textur;

	vector<Vektor> m_vertices;
	vector<SURFACE> m_surfaces;

	MaterialManager *m_matman;
	void CreateObject(Objekt *obj);
};

#endif /* LOADERAC_H_ */
